import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_video.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;

public class Thinning {
	public static void main(String args[]) {
		System.out.println("Started Thinning...");
		IplImage img = cvLoadImage("map2.bmp");
		IplImage gray = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 1);
		IplImage out = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 1);
		
		cvCvtColor(img, gray, CV_RGB2GRAY);
		//ThinningGonzalez(gray, out);
		
		cvNamedWindow("gray", CV_WINDOW_AUTOSIZE);
		cvNamedWindow("out", CV_WINDOW_AUTOSIZE);
		cvNamedWindow("origin", CV_WINDOW_AUTOSIZE);
		
		cvShowImage("gray", gray);
		cvShowImage("origin", img);
		cvShowImage("out", out);
		
		//cvReleaseImage(img);
		//cvReleaseImage(gray);
		//cvReleaseImage(out);
		
		cvWaitKey(0);
	}
	
	void ThinningGonzalez(IplImage inImg, IplImage outImg) {
		int width = cvGetSize(inImg).width();
		int height = cvGetSize(inImg).height();
		
		IplImage tmpImg = cvCreateImage(cvSize(width, height), 8, 1);
		
		BytePointer poutImg;
		
		
		for(int y=0;y<height;y++) {
			for(int x=0; x<width;x++) {
				outImg.imageData();
				outImg.imageData(arg0);
			}
		}
	}
}
